package boot3.mapper;

import boot3.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {
    //通过userID获取指定用户
    @Select("select * from user where userID = #{userID}")
    public User findByID(String id);
    //获取所有的用户信息
    @Select("select * from user")
    public List<User> findAll();
    //通过用户类型获取所有的符合条件的用户
    @Select("select * from user where type=#{type}")
    public List<User> findByType(String type);
    //修改指定userID用户的密码
    @Update("update user set password=#{NewPassword} where userID=#{userID}")
    public Boolean byIdAlterPassword(String userID,String NewPassword);
    //根据用户的ID获取用户的姓名
    @Select("select userName from user where userID=#{userID}")
    public String getUserName(String userID);
    //根据用户的ID修改用户的信息
    @Update("update user set ${item}=#{value} where userID=#{userID}")
    public Boolean setUserName(String userID,String value,String item);
    //添加新的用户
    @Insert("insert user value(#{userID},#{password},#{type},#{userName})")
    public Boolean addUser(User user);
    //根据用户的ID删除用户
    @Delete("delete from user where userID=#{userID}")
    public Boolean delUser(String userID);
}
